Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wip] layer-by-layer rendering #1197

Closed
wants to merge 13 commits into from
Closed

[wip] layer-by-layer rendering #1197

wants to merge 13 commits into from

Conversation

ansis
Copy link
Contributor

@ansis ansis commented May 2, 2015

This fixes #193 and fixes #757 and fixes #1156.

Rendering tests are all currently failing because it's lacking a depth buffer. I tried adding it with https://gist.github.com/ansis/d07edada904fad335520 but it's not working. The framebuffer status check is returning 36061 (FRAMEBUFFER_UNSUPPORTED). @kkaefer any ideas?

what my attempt at setting up a depth buffer looked like:
screen shot 2015-05-01 at 2 12 38 pm

Performance: It seems similar. Needs more careful testing. @mourner

With these changes rendering works more similarly to -native. All layers are drawn in two passes: opaque and then transparent. Tile clip ids are drawn to the stencil at the same time to allow for fast switching between tiles. The depth buffer is used to drop fragments below opaque fills..

I did not make any effort to name and structure things similarly to -native. We should reorganize things in both so that they are more similar.

Clip ids work a bit differently than in -native. Each source as it's own set of clip ids and the stencil mask is redrawn whenever it switches between sources. This approach us use less stencil bits (5). With only 5 bits we have 3 left over for drawing fills. This is what let me implement this before we merge the fill triangulation work. I also have concerns about whether -native's stencil clipping works properly across multiple sources.

@ansis ansis force-pushed the layer-by-layer branch from 2d0d97f to edc28e6 Compare May 2, 2015 00:24
@kkaefer
Copy link
Member

kkaefer commented May 2, 2015

You likely have to request a buffer that is a combination of depth and stencil buffer with something like GL_DEPTH24_STENCIL8_EXT

@jfirebaugh
Copy link
Contributor

I figured out the depth/stencil buffer issue, but there are still quite a few rendering test failures.

@jfirebaugh
Copy link
Contributor

World wrapping is broken -- the multiply-used z0 tile is being overdrawn because its matrix is always calculated using the wrapped coordinates in tile.coord rather than unwrapped coordinates.

@ansis
Copy link
Contributor Author

ansis commented May 11, 2015

I've been digging into some of the rendering test failures today and it looks like even though the depthstencil is set up properly the depth buffer isn't working.

The rendering tests only show something if depthFunc is set to pass fragments with equal z values (EQUAL, GEQUAL, LEQUAL). But clearing the depth buffer to a different z value has no effect. This seems like a contradiction. I'll try to set up an isolated test case to test if the depth buffer works.

@jfirebaugh
Copy link
Contributor

@ansis - It's possible my hack in ad59cd0 does not actually result in a depth buffer getting created on the headless-gl side. See stackgl/headless-gl#15.

ansis and others added 13 commits May 13, 2015 14:17
Instead of drawing the current tile's clipping area before starting a
triangle, draw clipping masks for all tiles at the beginning.

This will let us to switch to layer-by-layer rendering.
The first pass draws opaque objects top-down without blending.
The second pass draws translucent objects bottom-up with blending.

The depth buffer is used to drop fragments below opaque fills.
@ansis ansis force-pushed the layer-by-layer branch from ad59cd0 to 8fd9e8b Compare May 13, 2015 18:25
@ansis
Copy link
Contributor Author

ansis commented May 15, 2015

I'm stuck. From what I can tell depth writing and testing is working properly in the headless testing, but depthRange is not. depthRange should map the z values returned by the shader to a different range before doing depth testing and writing. It seems like depthRange has no effect.

Here's a separate case where the depthRange change should cause the second (blue) rectangle to get clipped. It doesn't get clipped. But if you change the depth values or the depth function they behave as I would expect them to if the depthRange calls weren't there.
https://gist.github.com/ansis/eb5010694c3d8bf77bb7

@kkaefer any ideas?

@tmcw tmcw changed the title layer-by-layer rendering [wip] layer-by-layer rendering May 26, 2015
@jfirebaugh jfirebaugh added this to the 0.9 milestone Jun 11, 2015
@ansis
Copy link
Contributor Author

ansis commented Jul 6, 2015

This is blocked by making both depth and stencil testing work for render tests. This means figuring out how to use a depthstencil in headless-gl or finding a different way to do render tests.

@jfirebaugh
Copy link
Contributor

Status update here: we believe that recent releases of stackgl/headless-gl should resolve the depth and stencil testing issues in headless rendering. However we've run into issues with using recent releases of stackgl/headless-gl in CI that need to be dug into. We're following that progress in #1447.

@jfirebaugh
Copy link
Contributor

We're now using headless-gl 2.0 and should check that this is unblocked as expected.

@jfirebaugh
Copy link
Contributor

#1727

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fix background pattern in perspective view Labels slipping/cropping at tile bounds drawing layer by layer
3 participants